package com.example.mys_app;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

public class tab2 extends Fragment {
    Context context;
    RecyclerView recyclerView;
    List<String> songList;
    List<String> songerList;

    @SuppressLint("MissingInflatedId")
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.tab2, container, false);

        recyclerView=view.findViewById(R.id.recyclerview2);

        // 创建一个歌单项的列表
        songList = new ArrayList<>();
        songList.add("七里香");
        songList.add("晴天");
        songList.add("兰亭序");

        songerList=new ArrayList<>();
        songerList.add("Jay");
        songerList.add("Jay");
        songerList.add("Jay");
        // ...

        // 创建自定义适配器
        SongAdapter adapter = new SongAdapter(getContext(), songList,songerList);
        // 设置适配器
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        recyclerView.setAdapter(adapter);

       return view;
    }
}